<?php
$this->breadcrumbs=array(
	'Events'=>array('index'),
	$model->name,
);

$this->menu=array(
	array('label'=>'List Event', 'url'=>array('index')),
	array('label'=>'Create Event', 'url'=>array('create')),
	array('label'=>'Update Event', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Event', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Event', 'url'=>array('admin')),
);
$like = Like::model()->findByPk($model->id);

?>
<div class="main-box border-line">
    <div class="main-title">
        <span>View Event: <?php echo $model->name; ?></span>
    </div>
    <div class="main-content">

    <div class="event-02">
        <div class="event-info-title title-bg"><?php echo $model->name; ?></div>
        <div class="event-info">
            <div class="event-info-time border-line border-round">
                <div class="event-info-start">12:30</div>
                <div class="event-info-date"><?php echo date ('d/m/Y',strtotime($model->date)); ?></div>
            </div>
            <div class="event-info-more">
            <div class="event-info-place">Place: <span><?php echo $model->place; ?></span></div>
            <div class="event-info-visit">Visit: <span><?php echo CHtml::encode($like->view); ?></span> Like: <span><?php echo CHtml::encode($like->like); ?></span></div>
<?php 
	if (!Yii::app()->user->isGuest)
	{
	$form = $this->beginWidget('CActiveForm', array(
		'id'=>'event-form',
		'enableAjaxValidation'=>false,
	));
?>
            <?php if (Yii::app()->user->id!==null):?>
            <?php if (Yii::app()->user->hasFlash('likeSubmitted')):?>
            <div class="flash-success">
                <blink><?php echo Yii::app()->user->getFlash('likeSubmitted');?></blink>
            </div>
            <?php else: ?>
                <?php echo CHtml::submitButton('Like');?>
                <?php //echo CHtml::submitButton('UnLike');?>
            <?php endif;?>
            <?php endif;?>
<div class="row">
	<?php echo $form->hiddenField($model,'id'); ?>
</div>
<?php
$this->endWidget(); }
	if (Yii::app()->user->id === $model->create_user_id)
	{
		echo CHtml::link("Update", array('/event/update', 'id'=>$model->id)); 
		echo " or ";
		echo CHtml::link("Delete", array('/event/delete', 'id'=>$model->id));
	}
	
?>          </div>
            <div class="clear"></div>
            
        </div>
        <div class="event-info-owner border-line border-round">
            Create by: <span><?php echo CHtml::link($model->user->username, array('users/viewprofiles', 'id'=>$model->create_user_id)) ?></span> - On Category: <span><?php echo CHtml::encode($model->idType->name); ?></span>
        </div>
    </div><!-- End Event -->


    </div>
</div>

<div id="comment" class="border-line">
    <?php if ($model->commentCount >= 1):?>
    <h3 class="title-bg">Total
        <?php echo $model->commentCount > 1 ? $model->commentCount.' comments' : 'One comment' ;?>
    </h3>
    
        <?php
            $this->widget('zii.widgets.CListView', array(
	           'dataProvider'=>$dataProvider,
	           'itemView'=>'_comments',
               'summaryText'=>"",
               'pager'=>array('header'=>"")
               ));
        ?>
    
    <? endif;?>
    <?php if (Yii::app()->user->id!==null):?>
    <h3 class="title-bg">Leave a Comment</h3>
    
    <?php if (Yii::app()->user->hasFlash('commentSubmitted')):?>
    
    <div class="flash-success">
        <?php echo Yii::app()->user->getFlash('commentSubmitted');?>
    </div>
    <?php $this->renderPartial('/comment/_form', array('model'=>$comment));?>
    <?php else: ?>
        <?php $this->renderPartial('/comment/_form', array('model'=>$comment));?>
    <?php endif;?>
    <?php endif;?>
</div>
<?php
	$same = Event::model()->sameEvent($model->id, $model->id_type);
?>
<div class="main-box border-line">
    <div class="main-title">
        <span>The same Events on <?php echo CHtml::encode($model->idType->name); ?></span>
    </div>
    <div class="main-content">
<div id="same-event">
<?php foreach($same as $line): ?>
<div class="event-line">
<div class="event-time">
<?php echo $line['date']; ?>
</div>
<div class="event-title">
<?php echo CHtml::link(CHtml::encode($line['name']), array('event/view', 'id'=>$line['id'])); ?>
<div class="event-title-button">
<?php echo CHtml::link('>', array('event/view', 'id'=>$line['id'])); ?>
</div>
</div>
</div>
<div class="clear"></div>
<?php endforeach; ?>
</div>
    </div>
</div>